-- 摆摊
require("TSLib")

local toucher = require("toucher")
local logger = require("logger")
local color = require("booth_color")
local M = {}


function M.is_open(...)
	if (isColor( 300,  100, 0xc1936a, 85)) 
    then
		logger.debug("摊位已经打开，我要出售栏目")
		return true
	end
	x,y = color.find_add_button()
	if x ~= -1 and y ~= -1 
	then
		logger.debug("摊位已经打开，等待上架")
		return true
	end
	return false
end

function M.click_to_sell(...)
	x,y = color.find_add_button()
	if x ~= -1 and y ~= -1 then
		toucher.click(x,y)
		mSleep(1000)
		for i = 1, 15, 1 do
			toucher.click(600,200)
			mSleep(1000)
			toucher.click(920,560)
			mSleep(1000)
		end
	end
end


function M.close_sell_window(...)
	x,y = color.find_close_button()
	if x ~= -1 and y ~= -1 then
		toucher.click(x,y)
		mSleep(1000)
	end
end

function main(...)
	init(1)
	M.click_to_sell()
	M.close_sell_window()
end

main()

return M